<?php

/**
 * Error wrapper, set as default error handler
 *
 * @package yzFramework
 * @author Tomasz Slominski, <tomasz@yzeo.fr>
 * @version 1.0
 * @param int $nErrorNumber
 * @param string $sErrorString
 * @param string $sErrorFile
 * @param int $nErrorLine
 * @param array $aErrorContext
 * @throws Exception
 *
 */
function __error($nErrorNumber, $sErrorString,  $sErrorFile, $nErrorLine, $aErrorContext){

	if ($nErrorNumber & error_reporting()){

		throw new yzException($sErrorString,$nErrorNumber,$sErrorFile,$nErrorLine);

		return true;

	} // if

	return false;

} // function

/**
 * Exception handler
 *
 * @package yzFramework
 * @author Tomasz Slominski, <tomasz@yzeo.fr>
 * @version 1.0
 * @param exception $oException
 *
 *
 */
function __exception($oException){

 	die($oException->getMessage());

} // function

/**
 * Class loader
 *
 * @package yzFramework
 * @author Tomasz Slominski, <tomasz@yzeo.fr>
 * @version 1.0
 * @param string $sClassName
 *
 */
function __autoload($sClassName){

	$sFile = dirname(__FILE__).'\\eng\\'.$sClassName.'.php';

	if (realpath($sFile)){

		require_once($sFile);

	} else{

		require_once(dirname(__FILE__).'\eng\yzGenerator.php');

		$oGenerator = new yzGenerator();

		if (($sFile=$oGenerator->generateControler($sClassName))!==false){

			require_once($sFile);

		} else {

		  throw new yzException('! '.$sClassName.' < '.$sFile);

		  return false;

		}

	} // if

} // function

if (version_compare(PHP_VERSION, '5.2', '<')==1 ){

	require_once('compat.php');

} // if

require_once('functions.php');

require_once('aliases.php');

// setting necessary handlers

set_error_handler('__error');

set_exception_handler('__exception');

error_reporting(E_ALL | E_STRICT);

session_start();

?>